package com.sxdz.exception

import com.sxdz.constant.CommonConstant
import org.springframework.boot.autoconfigure.web.ErrorController
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping

import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

/**
 * Created by zb on 2015/6/12.
 */
@Controller
class NoPageErrorAction implements ErrorController {

    private static final String ERROR_PATH = "/error";

    /**
     * 找不到页面，即404错误
     * @param req
     * @param res
     */
    @RequestMapping("/error")
    void handleError(HttpServletRequest req, HttpServletResponse res){
        req.getRequestDispatcher("/error/"+CommonConstant.ErrorMsg.E404.value).forward(req, res)
    }

    @Override
    public String getErrorPath() {
        return ERROR_PATH;
    }

}
